package com.chinasofti.collection;

public class MathDemo {
    public static void main(String[] args) {
        int abs = Math.abs(-10);//返回一个数的绝对值
        System.out.println(abs);

        double ceil = Math.ceil(10.1);
        System.out.println("ceil = " + ceil);//向上取整数

        double floor = Math.floor(10.1);
        System.out.println("floor = " + floor);//向下取整数

        //四舍五入
        long round1 = Math.round(1.9);
        System.out.println("round = " + round1);
        long round2 = Math.round(2.1);
        System.out.println("round = " + round2);

        //返回两个数的最大值
        int max = Math.max(10,20);
        System.out.println("max = " + max);

        int min = Math.min(20,30);
        System.out.println("min = " + min);

        double pow = Math.pow(2,3);//返回a的b次幂
        System.out.println("pow = " + pow);

        for (int i=0;i<10;i++){
            double random = Math.random();//返回[0,1)
            System.out.println(random);
        }

    }
}
